package edu.sctu.practice.class01.xiangkun.assign03.demoone;

/**
 * Created by xiangkun on 2015/11/5.
 */
public class TestPolymorphism {

    public static void main(String[] args) {
        GeometricObject geoObject1 = new Circle(6);
        GeometricObject geoObject2 = new Rectangle(6, 3);
        System.out.println("这两个图形的面积相等吗？ " + equalArea(geoObject1, geoObject2));
        displayGeometricObject(geoObject1);
        displayGeometricObject(geoObject2);
    }

    static boolean equalArea(GeometricObject object1, GeometricObject object2) {
        return object1.findArea() == object2.findArea();
    }

    static void displayGeometricObject(GeometricObject object) {
        System.out.println();
        System.out.println(object.toString());
        System.out.println("面积是 " + object.findArea());
        System.out.println("周长是 " + object.findPerimeter());
    }

}
